package com.font.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.font.bean.Bing;
import com.font.bean.ciyun;
import com.font.mapper.BingMapper;
import com.font.service.BingService;
import com.font.service.DockerService;
import com.font.service.IntroduceService;
import com.font.service.MedicineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.xml.ws.Action;
import java.util.*;

/**
 * (Bing)表服务实现类
 *
 * @author makejava
 * @since 2023-08-15 13:57:29
 */
@Service("bingService")
public class BingServiceImpl extends ServiceImpl<BingMapper, Bing> implements BingService {
    @Autowired
    DockerService dockerService;

    @Autowired
    IntroduceService introduceService;

    @Autowired
    MedicineService medicineService;



    @Override
    public List<ciyun> ciyunlist() {
        return this.getBaseMapper().ciyunlist();
    }

    @Override
    public List<ciyun> ciyun2list() {

        List<String> list = this.getBaseMapper().ciyun2list();
        List<String> list1 = this.getBaseMapper().ciyun3list();
        list.addAll(list1);
        List<String> list2 = new ArrayList<>();
        List<ciyun> list3 = new ArrayList<>();

        for (String s : list) {
            list2.addAll( Arrays.asList(s.split(",|，|。|，")));
        }

        for (int i = 0; i < list2.size(); i++) {
            ciyun ciyun = new ciyun(list2.get(i),String.valueOf(i));
            list3.add(ciyun);
        }
        return list3;
    }

    @Override
    public List<ciyun> ciyun4list() {
        return this.getBaseMapper().ciyun4list();
    }

    @Override
    public Map<String, Object> counts() {
        Integer bing = this.getBaseMapper().selectCount(null);
        int medicine = medicineService.count();
        int introduce = introduceService.count();
        int docker = dockerService.count();
        HashMap<String, Object> map = new HashMap<>();
        map.put("bing",bing);
        map.put("medicine",medicine);
        map.put("introdice",introduce);
        map.put("docker",docker);
        return map;
    }
}
